package com.ysm.smfu.fragment;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.umeng.analytics.MobclickAgent;
import com.ysm.smfu.R;
import com.ysm.smfu.StatusBarCompat;
import com.ysm.smfu.activity.FoundActivity;
import com.ysm.smfu.utils.UIUtils;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2016/9/19.
 */
public class FoundFragment extends MyBaseFragment {

    @BindView(R.id.activity_main_top_bar)
    AutoRelativeLayout activity_main_top_bar;
    @BindView(R.id.fragment_found_bendifuwu)
    AutoRelativeLayout fragmentFoundBendifuwu;
    @BindView(R.id.fragment_found_onLineStore)
    AutoRelativeLayout fragmentFoundOnLineStore;
    @BindView(R.id.back)
    ImageView back;
    @BindView(R.id.title_body)
    TextView titleBody;
    @BindView(R.id.mainActivity_topbar_img)
    ImageView mainActivityTopbarImg;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = UIUtils.inflate(R.layout.fragment_found);
        ButterKnife.bind(this, view);
        titleBody.setText("发现");
        mainActivityTopbarImg.setVisibility(View.GONE);
        back.setVisibility(View.GONE);
        initTopBar();
        return view;
    }

    /**
     * 沉浸式状态栏实现
     */
    private void initTopBar() {
//        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        StatusBarCompat.compat(getActivity(), getResources().getColor(R.color.green));
        AutoLinearLayout.LayoutParams layoutParams = (AutoLinearLayout.LayoutParams) activity_main_top_bar.getLayoutParams();
        layoutParams.topMargin = StatusBarCompat.getStatusBarHeight(getContext());
        activity_main_top_bar.setLayoutParams(layoutParams);
//        }
    }

    @OnClick({R.id.fragment_found_bendifuwu, R.id.fragment_found_onLineStore})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.fragment_found_bendifuwu:
                UIUtils.startActivity(FoundActivity.class, "found", 0);
                break;
            case R.id.fragment_found_onLineStore:
                UIUtils.startActivity(FoundActivity.class, "found", 1);
                break;
        }
    }
}
